package org.tang.sharding.jdbc.controller;

import org.tang.sharding.jdbc.entity.OrderInfo;
import org.tang.sharding.jdbc.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * 订单信息
 */
@RestController
public class OrderInfoController {

    @Autowired
    private OrderInfoService orderInfoService;

    @PostMapping(value = "/order/findById")
    public Optional findById(@RequestParam("id") Long id) {
        return orderInfoService.findById(id);
    }

    @PostMapping(value = "/order/save")
    public String saveOrderInfo(@RequestParam("count") Integer count) {
        orderInfoService.save( count);
        return "保存成功";
    }

    @PostMapping(value = "/order/getAllOrderList")
    public List<OrderInfo> getAllOrderList() {
        return orderInfoService.getAll();
    }



}
